package com.xinghou.platform.dao.mange.control;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.xinghou.platform.dao.mange.service.LoadResourceService;
import com.xinghou.platform.dao.mange.service.MessageDAOService;
import com.xinghou.platform.dao.mange.service.UserInfoDAOService;
import com.xinghou.platform.dao.mange.service.VestDAOService;
@Controller
@RequestMapping("/login") 
public class LoginActionControl {
	@Resource
	private MessageDAOService messageDAOService;
	@Resource
	private UserInfoDAOService userinfoDAOService;
	@Resource
	private VestDAOService vestDAOService;
	@Resource
	private LoadResourceService loadResourceService;
	
	@RequestMapping(value = "/login.action")
	public String index(){
		
		return "login";
	}
	
	@RequestMapping(value = "/main.action")
	public String main(HttpServletRequest request){
		String user=request.getParameter("user");
		String password=request.getParameter("password");
		loadResourceService.start();
		int ret=vestDAOService.getVest(user, password);
		if(ret>0)
		{
			int vestId=vestDAOService.getVestId(user);
			request.setAttribute("vestId", vestId);
			return "main";
		}else{
			
			return "failed";
		}
		
	}
	
	
}
